<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">首页数据列表</div>
                </div>
                <div class="widget-body am-fr">
                    <div class="page_toolbar am-margin-bottom-xs am-cf">
                        <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                            <div class="am-form-group">
                                <div class="am-btn-toolbar">
                                    <?php if (checkPrivilege('goods.goods/add')): ?>
                                        <div class="am-btn-group am-btn-group-xs">
                                            <a class="am-btn am-btn-default am-btn-success am-radius"
                                               href="<?= url('goods.goods/add') ?>">
                                                <span class="am-icon-plus"></span> 新增
                                            </a>
                                        </div>
                                    <?php endif; ?>
                                </div>
                            </div>
                        </div>
                        <form class="toolbar-form" action="">
                            <input type="hidden" name="s" value="/<?= $request->pathinfo() ?>">
                            <div class="am-u-sm-12 am-u-md-9 am-u-sm-push-3">
                                <div class="am fr">
                                    <div class="am-form-group am-fl">
                                        <?php $gender = $request->get('type'); ?>
                                        <select name="type"
                                                data-am-selected="{btnSize: 'sm', placeholder: '请选择数据类型'}">
                                            <option value=""></option>
                                            <option value="1"
                                                <?= $gender === '1' ? 'selected' : '' ?>>logo位
                                            </option>
                                            <option value="2"
                                                <?= $gender === '2' ? 'selected' : '' ?>>广告位
                                            </option>
                                            <option value="3"
                                                <?= $gender === '3' ? 'selected' : '' ?>>通知栏
                                            </option><option value="4"
                                                <?= $gender === '4' ? 'selected' : '' ?>>销售榜单
                                            </option>


                                        </select>
                                    </div>
                                    <div class="am-form-group am-fl">
                                        <div class="am-input-group am-input-group-sm tpl-form-border-form">
                                            <input type="text" class="am-form-field" name="title"
                                                   placeholder="请输入标题/名称/内容"
                                                   value="<?= $request->get('title') ?>">
                                            <div class="am-input-group-btn">
                                                <button class="am-btn am-btn-default am-icon-search"
                                                        type="submit"></button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>

                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped
                         tpl-table-black am-text-nowrap">
                            <thead>
                            <tr>
                                <th>数据ID</th>
                                <th>图片</th>
                                <th>数据类型</th>
                                <th>标题</th>
                                <th>名称</th>
                                <th>内容</th>
                                <th>状态</th>
                                <th>添加时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if (!$list->isEmpty()): foreach ($list as $item): ?>
                                <tr>
                                    <td class="am-text-middle" id="<?= $item['id'] ?>"><?= $item['id'] ?></td>
                                    <td class="am-text-middle">
                                        <?php if ($item['type']!=3): ?>
                                        <a href="<?= getImage($item['imageId']) ?>"
                                           title="点击查看大图" target="_blank">
                                            <img src="<?= getImage($item['imageId']) ?>"
                                                 width="50" height="50" alt="商品图片">
                                        </a>
                                        <?php endif; ?>
                                        <?php if ($item['type']==3): ?>
                                            <p class="item-title" >暂无</p>
                                        <?php endif; ?>
                                    </td>
                                    <td class="am-text-middle">
                                        <p class="item-title" ><?= gettypes1($item['type'])?></p>
                                    </td>
                                    <td class="am-text-middle">
                                        <p class="item-title"><?= getstr($item['title'] ) ?></p>
                                    </td>

                                    <td class="am-text-middle"><?= getstr($item['name'] ) ?></td>
                                    <td class="am-text-middle"><?= getstr($item['content']) ?></td>
                                    <td class="am-text-middle"><?= getstatus($item['status']) ?></td>

                                    <td class="am-text-middle"><?= gettimes($item['create_time']) ?></td>
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
                                            <?php if (checkPrivilege('goods.goods/edit')): ?>
                                                <a href="<?= url('goods.goods/edit',
                                                    ['id' => $item['id']]) ?>">
                                                    <i class="am-icon-pencil"></i> 编辑
                                                </a>
                                            <?php endif; ?>
                                            <?php if ($item['status']==1): ?>

                                                <a href="javascript:void(0);"
                                                   class="item-delete tpl-table-black-operation-del"
                                                   data-id="<?= $item['id'] ?>">
                                                    <i class="am-icon-trash"></i> 删除
                                                </a>
                                            <?php endif; ?>
                                            <?php if ($item['status']==2): ?>

                                                <a href="javascript:void(0);"
                                                   class="item-delete2 tpl-table-black-operation-del"
                                                   data-id="<?= $item['id'] ?>">
                                                    <i class="am-icon-trash"></i> 恢复
                                                </a>
                                            <?php endif; ?>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; else: ?>
                                <tr>
                                    <td colspan="9" class="am-text-center">暂无记录</td>
                                </tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr"><?= $list->render() ?> </div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：<?= $list->total() ?></div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
<script>


    $(function () {
        // 删除元素
        var url = "<?= url('goods.goods/delete') ?>";
        $('.item-delete').delete('id', url, '确定要删除吗？');
        // 恢复元素
        var url1 = "<?= url('goods.goods/recover') ?>";
        $('.item-delete2').delete('id', url1, '确定要恢复吗？');
        // 商品状态
        $('.js-down').click(function () {
            // 验证权限
            if (!"<?= checkPrivilege('goods.goods/offdown')?>") {
                return false;
            }
            var data = $(this).data();
            var str="<div class=\"row-content am-cf\">\n" +
                "    <div class=\"row\">\n" +
                "        <div class=\"am-u-sm-12 am-u-md-12 am-u-lg-12\">\n" +
                "            <div class=\"widget am-cf\">\n" +
                "                <form id=\"my-form\" class=\"am-form tpl-form-line-form\" method=\"post\">\n" +
                "                    <div class=\"widget-body\">\n" +
                "                        <fieldset>\n" +
                "                            <div class=\"am-form-group\">\n" +
                "                                <label class=\"am-u-sm-3 am-u-lg-2 am-form-label form-require\">消息标题  </label>\n" +
                "                                <div class=\"am-u-sm-9 am-u-end\">\n" +
                "                                    <input type=\"text\" id='title' class=\"tpl-form-input\" name=\"message_title\"\n" +
                "                                           value=\"\" required>\n" +
                "                                </div>\n" +
                "                            </div>\n" +
                "                            <div class=\"am-form-group\">\n" +
                "                                <label class=\"am-u-sm-3 am-u-lg-2 am-form-label form-require\">行业描述 </label>\n" +
                "                                <div class=\"am-u-sm-9 am-u-end\">\n" +
                "                                    <textarea cols=\"100\" rows=\"10\"  id='content' name=\"message_content\"></textarea>\n" +
                "                                </div>\n" +
                "                            </div>\n" +
                "                        </fieldset>\n" +
                "                    </div>\n" +
                "                </form>\n" +
                "            </div>\n" +
                "        </div>\n" +
                "    </div>\n" +
                "</div>";

            layer.confirm(str,{btn: ['确定', '取消'], area:["700px","500px"], title: "下架通知"}, function (index, layero) {
                var title = $(layero).find('#title').val();
                var content = $(layero).find('#content').val();;
                    $.post("<?= url('goods.goods/offdown') ?>"
                        , {
                            goods_id: data.id,
                            message_title:title,
                            message_content:content,
                        }
                        , function (result) {
                            result.code === 1 ? $.show_success(result.msg, result.url) : $.show_error(result.msg);
                        });
                    layer.close(index);
                });
        });



    });

</script>

